using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace EfSessionStateProvider
{
    public partial class SessionStateContext : DbContext
    {
        static SessionStateContext()
        {
            Database.SetInitializer(new CreateDatabaseIfNotExists<SessionStateContext>());
        }

        public SessionStateContext(string nameOrConnectionString)
            : base(nameOrConnectionString ?? "Name=SessionStateContext")
        {
#if DEBUG
            this.Database.Log = o => System.Diagnostics.Debug.WriteLine(o);
#endif
        }

        public DbSet<ASPStateTempSession> Sessions { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
            modelBuilder.Configurations.Add(new ASPStateTempSessionMap());
        }
    }
}